﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
<title>老师设定</title>
<script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";

    $(function(){
    	
    	//$("#date").ligerDateEditor();
    	$("#dateExpire").ligerDateEditor();
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        //if(viewType=="modify"){
        	 $("#terId").attr("readonly", "readonly").removeAttr("validate");
        //}
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        $.validator.addMethod('sexChecker', function(value) {
        	if (value != -1)
    			return true;
    		else  
    			return false;
            }, '请选择性别'); 
        
        // 给性别赋值
        var tSex="${command.terSex}";        
        if(tSex=='0'){
        	$("#terSex").val(0);
        }else if(tSex=='1'){
        	$("#terSex").val(1);
        }else{
        	$("#terSex").val(-1);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

        //调整form-bar
        $(".form-bar").css("width","630px");  
    });
   
    function save(){
    	if($("#terSex").val()=='-1'){
    		LG.showError('请选择性别');
    	}else{
    		LG.submitForm(mainform, function (result) {
            	if(typeof(result)=="string"){
            		result=eval("("+result+")");
            	}
                if (!result.success) {
                    LG.showError('错误:' + result.message);
                }
                else { 
                    LG.showSuccess('保存成功', function () { 
                       LG.callParent("terList");
                    });
                }
            });
    	}
        
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>

<body>
<form name="mainform" method="post" id="mainform" action="${ctx }/qso/teacher/save">
<input type="hidden" name="viewType" value="${viewType}" />
<table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top: 10px; margin-left: 15px;">
	<tr>
		<td align="right" class="l-table-edit-td" style="width:15%;">老师编号:</td>
		<td align="left" class="l-table-edit-td" style="width:35%;">${command.terId} 
			<input name="terId" type="hidden" id="terId" value="${command.terId}" ltype="text" />
		</td>
		<td align="right" class="l-table-edit-td" style="width:15%;">老师姓名:</td>
		<td align="left" class="l-table-edit-td" style="width:35%;">
			<input name="terName" type="text" id="terName" value="${command.terName}" ltype="text" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> />
		</td>
	</tr>
	<tr>
		<td align="right" class="l-table-edit-td">老师性别:</td>
		<td align="left" class="l-table-edit-td">
		<select id="terSex" name="terSex" validate="{required:true, sexChecker:true}" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> >
			<option value="-1">请选择</option>
			<option value="0">男</option>
			<option value="1">女</option>
		</select></td>
		<td align="right" class="l-table-edit-td">老师电话:</td>
		<td align="left" class="l-table-edit-td">
		<input name="terTel" type="text" id="terTel" value="${command.terTel}" maxlength="15" ltype="text" validate="{required:true, digits:true, notnull:true}" nullText="不能为空" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> />
		</td>
	</tr>
	<tr>
		<td align="right" class="l-table-edit-td" valign="top">老师邮箱:</td>
		<td align="left" class="l-table-edit-td">
		<input name="terMail" type="text" id="terMail" value="${command.terMail}" format="yyyy" validate="{required:true, notnull:true, email:true}" nullText="不能为空" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> />
		</td>
		
		<td align="right" class="l-table-edit-td" valign="top">登录账号:</td> 
		<td align="left" class="l-table-edit-td"> 
		<c:if test="${viewType=='add'}">
			<input name="terUserId" type="text" id="terUserId" maxlength="30" value="${command.terUserId}" validate="{required:true}" />
		</c:if> 
		<c:if test="${viewType!='add'}">${command.terUserId} 
			<input name="terUserId" type="hidden" id="terUserId" value="${command.terUserId}" />
		</c:if> 
       </td>
	</tr>
	<tr>
		<td align="right" class="l-table-edit-td" valign="top">过期日期:</td>
		<td align="left" class="l-table-edit-td">
			<c:if test="${viewType!='detail'}">
				<input name="dateExpire" type="text" id="dateExpire" value="${command.dateExpire}" ltype="date" format="yyyy-MM-dd" validate="{required:true}" />
			</c:if>	
			<c:if test="${viewType=='detail'}">
				<input type="text" value="${command.dateExpire}" ltype="date" format="yyyy-MM-dd" validate="{required:true}" disabled="disabled" />
			</c:if>	
		</td>
	</tr>
	<tr>
		<td align="right" class="l-table-edit-td">备注:</td>
		<td align="left" class="l-table-edit-td" colspan="4"><textarea
			cols="100" rows="3" class="l-textarea" id="remark" name="remark"
			style="width: 470px" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if>>${command.remark}</textarea></td>
		<td align="left"></td>
	</tr>
</table>
</form>
</body>
</html>
